package com.liu.cloud.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LIU
 * @version 1.0
 * @description: TODO
 * @date 2023/6/18 12:49
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {



    @RequestMapping("/add")
    public String add(){
        return  "添加成功";
    }


    @RequestMapping("/flow")
    @SentinelResource(value = "flow",blockHandler = "flowBlockHandler")
    public String flow(){
        return  "访问成功";
    }
    /**
     * @description 自定义流控处理
     * @author liuzq
     * @date 2023/7/29 15:05
     * @param e
     * @return String
     */
    public String flowBlockHandler(BlockException e){
        log.error("流控成功",e);
        return  "流控成功";
    }


}
